﻿package com.project.webapp.interceptor;

/**
 * description:每一个Action都要被此拦截器拦截，此拦截器的目的是：打印出每次请求执行的路径
 * 1. 进入Action的method时记录log
 * 
 */

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.project.webapp.action.BaseAction;

public class CommonInterceptor extends AbstractInterceptor {

    private static final long serialVersionUID = 1L;

    public String intercept(ActionInvocation invocation) throws Exception {

        // 进入Action的method时记录log
        if (invocation.getAction() instanceof BaseAction) {
            BaseAction baseAction = (BaseAction) invocation.getAction();
            baseAction.log.info(invocation.getAction().getClass().getName() + "."
                                + invocation.getProxy().getMethod() + "()");
        }
        String result = invocation.invoke();
        return result;
    }

}
